<%@ page language="java" pageEncoding="utf-8"%>
<%@ include file="../../includes/importer.jsp"%>
<!doctype html>
<html>
<head>
    <ht:head/>
<script src="<spring:url value="/static/js/uploadify/jquery.uploadify.js"/>" type="text/javascript" charset="utf-8"></script>
<link href="<spring:url value="/static/js/uploadify/uploadify.css"/>" rel="stylesheet" type="text/css" />
<script type="text/javascript">
    $(function() {
    	//获取来源地址
	 	var url = document.referrer;
	 	$("#backUrl").val(url);
	 	
	 	//上传分类logo图片
		$("#uploadPropertyPic").uploadify({
			height        : 25,
			removeCompleted:true,
			swf           : G_CTX_ROOT + '/static/js/uploadify/uploadify.swf',
			width         : 90,
			uploader:  "${ctx}/imgUpload/type/${uploadImgId};jsessionid=<%=request.getRequestedSessionId()%>",
							onUploadSuccess : function(file, data, response) {
								var timestamp = new Date().getTime();
								$("#logoImg").attr("src", data + "?d=" + timestamp);
								$("#imgPath").val(data);
							}
						});

	});
    
    function subFom() {
    	var imgPath = $("#imgPath").val();
    	if(!imgPath) {
	    	simpleWarn("请上传图片!", null);
	    	return false;
    	}
    }
</script>
</head>
<body>


<div id="content">
<!-- forms -->
<div class="box">
    <!-- box / title -->
    <div class="title">
        <h5><c:if test="${method == 'add'}">添加</c:if><c:if test="${method == 'edit'}">修改</c:if><c:if test="${sysType.type == 1}">商户分类</c:if><c:if test="${sysType.type == 2}">商品分类</c:if><c:if test="${pName == 0}">节点类型</c:if></h5>
    </div>
    <!-- end box / title -->
    <form:form method="post" id="fm" commandName="sysType" htmlEscape="true" acceptCharset="utf-8" cssClass="required-validate">
        <form:hidden path="pId" />
		<form:hidden path="type" />
		 <input type="hidden" id="backUrl" name="backUrl" />
        <div class="form">
            <div class="fields">
            	<c:if test="${method == 'add'}">
                <div class="field">
                    <div class="label noinput">ID：</div>
                    <div class="input">自动生成</div>
                </div>
                </c:if>
                <c:if test="${method == 'edit'}">
                <div class="field">
                    <div class="label noinput">ID：</div>
                    <div class="input">${sysType.id}</div>
                </div>
                </c:if>
                <div class="field">
                    <div class="label noinput">类型：</div>
                    <div class="input"><c:if test="${empty sysType.type}"><input type="text" name="type" id="type" value="${type}" /></c:if><c:if test="${sysType.type == 1}">商户</c:if><c:if test="${sysType.type == 2}">商品</c:if></div>
                </div>	
                <div class="field">
                    <div class="label noinput">上级<c:if test="${sysType.type == 1}">商户</c:if><c:if test="${sysType.type == 2}">商品</c:if>：</div>
                    <div class="input"><c:if test="${pName == 0}">无</c:if><c:if test="${pName != 0}">${pName}</c:if></div>
                </div>			
                <div class="field">
                    <div class="label">
                        <label for="name" class="req">名称：</label>
                    </div>
                    <div class="input"><!-- small medium large -->
                        <form:input path="name" cssClass="small required min-length-0 max-length-20" maxlength="20" />
                    	<span class="error" id="advice-required-name" style="display:none"></span>
                        <span class="error" id="advice-min-length-name" style="display:none"></span>
                        <span class="error" id="advice-max-length-name" style="display:none"></span>
                        <span class="error" id="advice-server-name" style="display:none"></span>
                    </div>
                </div>
                
                <div class="field">
                    <div class="label">
                        <label for="isValid" class="req">是否显示:</label>
                    </div>
                    <div class="select">
                        <select name="isValid" class="required">
			                <c:forEach items="${isValidMap}" var="item">
			                	    <option value="${item.key}" <c:if test="${sysType.isValid == item.key}">selected="selected"</c:if>>${item.value }</option>
			                </c:forEach>
		                </select>
                        <span class="error" id="advice-required-isValid" style="display:none"></span>
                    </div>
                </div>
                
                 <div class="field">
                    <div class="label">
                    	<label for="uploadfile" class="req">分类LOGO：</label>
	                    </div>
	                    <div class="input">
	                    	<c:if test="${method == 'add'}">
		                    	<img src="${ctx }/static/images/zwtp.png" id="logoImg" style="background: #ECE9D8" height="95" width="130">
			                </c:if>
			                <c:if test="${method == 'edit'}">
			                	<img src="${sysType.imgPath }" id="logoImg" style="background: #ECE9D8" height="95" width="130">
			                </c:if>
	                    </div>
	                    <div class="input" style="width: 120px;" >
	                    	<input type="file" id="uploadPropertyPic" name="uploadPropertyPic" style="display:none; margin-left: 10px;"  size="0" />
	                    	<input type="hidden" name="imgPath" id="imgPath" value="${sysType.imgPath }" cssClass="required">
	                   	</div>
	                    <div class="img-size-desc" style="margin-left: 79px; color: red;">建议图片大小为 800*800 或 600*600</div>
                	</div>
                
                <div class="buttons">
                    <div class="highlight">
                        <input type="submit" name="submit.highlight" value="提交" onclick="return subFom()" />
                    </div>
                    <input type="reset" name="reset" value="重置" />
                    <a href="javascript:history.go(-1)" class="btnAnchor">返回</a>
                </div>
            </div>
        </div>
    </form:form>
</div>
<!-- end forms -->
</div>


</body>
</html>